package com.aiyige.page.publish.guarantee;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.aiyige.R;
import com.aiyige.arouter.config.ARouterConfig;
import com.aiyige.page.publish.guarantee.adapter.GuaranteeAdapter;
import com.aiyige.page.publish.guarantee.adapter.GuaranteeShowAdapter;
import com.aiyige.page.publish.guarantee.model.GuaranteeItem;
import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;

import java.util.LinkedList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

@Route(path = ARouterConfig.GuaranteeShowPage)
public class GuaranteeShowPage extends AppCompatActivity {

    @BindView(R.id.titleBackBtn)
    ImageView titleBackBtn;
    @BindView(R.id.titleTv)
    TextView titleTv;
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    GuaranteeShowAdapter guaranteeShowAdapter;
    @Autowired
    GuaranteeItem[] guaranteeItemArray;
    List<GuaranteeItem> guaranteeItemList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.page_guarantee_show);
        ButterKnife.bind(this);
        ARouter.getInstance().inject(this);
        guaranteeItemList = new LinkedList<>();
        if (guaranteeItemArray != null) {
            for (GuaranteeItem guaranteeItem : guaranteeItemArray) {
                guaranteeItemList.add(guaranteeItem);
            }
        }
        titleTv.setText(R.string.guarantee);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        guaranteeShowAdapter = new GuaranteeShowAdapter();
        recyclerView.setAdapter(guaranteeShowAdapter);
        guaranteeShowAdapter.setNewData(guaranteeItemList);
    }

    @OnClick({R.id.titleBackBtn})
    public void onViewClicked(View v) {
        switch (v.getId()) {
            case R.id.titleBackBtn:
                finish();
                break;
        }
    }
}
